package com.wolf.gulimall.seckill.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务
 */
@Slf4j
@Component
@EnableAsync //开启异步任务
@EnableScheduling //开启定时任务
public class HelloScheduled {

    /**
     * 定时任务不应该被阻塞,默认就是阻塞的,使用异步任务
     * 使用异步加定时任务,实现定时任务不阻塞功能
     */
    @Async //标注异步执行任务
    //@Scheduled(cron = "* * * * * ?")
    public void hello(){
        log.info("hello");
    }


}
